package com.onesports.intelligent.k12.polarlight.service.student;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.onesports.intelligent.k12.polarlight.domain.dto.student.StudentManageDTO;
import com.onesports.intelligent.k12.polarlight.domain.entity.student.Student;
import com.onesports.intelligent.k12.polarlight.domain.vo.student.StudentManageVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.student.StudentVO;
import com.onesports.intelligent.k12.polarlight.mapper.course.ClassStudentMapper;
import com.onesports.intelligent.k12.polarlight.mapper.student.StudentMapper;
import com.onesports.intelligent.k12.polarlight.security.SecurityUtils;
import com.onesports.intelligent.k12.polarlight.util.BeanCopyUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author FPH
 * @since 2022年7月13日09:22:57
 */
@Service
@RequiredArgsConstructor
public class StudentService extends ServiceImpl<StudentMapper, Student> {

    private final StudentMapper studentMapper;

    private final ClassStudentMapper classStudentMapper;
    /**
     * 根据ID集合获取StudentVO
     * @param ids
     * @return
     */
    public List<StudentVO> queryStudentByIds(List<String> ids){
        List<Student> list = list(new LambdaQueryWrapper<Student>().in(Student::getId, ids));
        return BeanCopyUtil.copyListProperties(list,StudentVO::new);
    }



    /**
     * 学员管理列表
     * @param dto
     * @return
     */
    public IPage<StudentManageVO> page(StudentManageDTO dto){
        Page<StudentManageVO> asd = new Page<>(dto.getPage(),dto.getRow());
        return studentMapper.getPage(asd,dto, SecurityUtils.getOrganizationId());
    }
}
